<template>
  <div>
    <TopFilter
      :list="topFilterInit"
      :cols="3"
      labelWidth="90"
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
    ></TopFilter>
    <!-- table -->
    <FilterTable
      height="250"
      ref="listModal"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
      :onRowSelectChange="selectChange"
        columnsRef="notification_maintain_oemRole_01"
    ></FilterTable>

    <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">确定</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getUserRoleName } from '@/api/admin/notice/dcsNoticeMaintain/index';
export default {
  mixins: [dictionary],
  data() {
    return {
      topFilterInit: this.topFilterInitFun(),
      columns: this.creatHeader(),
      fetchApi: getUserRoleName, // TODO 缺少获取车场角色接口
      fetchParams: {
      },
      //dataSource: this.createDictList('1006'),
      selectedRows: null
    };
  },
  methods: {
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '角色代码', fieldName: 'roleCode', placeholder: '请输入', initialValue: '' },
        { type: 'INPUT', label: '角色名称', fieldName: 'roleName', placeholder: '请输入', initialValue: '' },
      ];
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '角色代码', dataIndex: 'roleCode', sorter: true },
        { title: '角色名称', dataIndex: 'roleName', sorter: true }
      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows });
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false });
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({}, val);
      console.log('搜索框数据：', this.fetchParams);
    },
    //展开收起时触发
    collapseHandle() {}
  }
};
</script>

<style lang="less" scoped>
</style>
